home *** CD-ROM | disk | FTP | other *** search
- Aug 12, 1989
- BITVAL and BITSTR Updated 7/28/90 for QBX/BC7 far string compatibility
-
- This ARC contains the MASM source and .OBJ for a set of bit-level
- manipulation routines to use with QB/BC. If you make modifications, you'll
- need MASM 5.1 to reassemble.
-
- Routines are included to set, clear, toggle and examine the state of any
- single bit in a 16-bit word. These allows the programmer to maintain 16
- separate flags in a single integer, with quick access to any flag. If you
- use global flags, you'll find these fast and convenient.
-
- Also included are routines to convert between numeric values and binary
- strings, for example "10011".
-
- Uploaded to MSSYS for the free use of its members. Not copyrighted.
- If you find these useful, drop me a note. Likewise, if you encounter any
- problems or have comments or questions, please let me know at once:
-
- Jim Mack [76630,2012] via MSSYS
-
- Detailed descriptions follow. Also see the MASM source and the QB test
- program for more information.
-
-
-
- ═══════════════
-
- DECLARE SUB SetBit (bitnumber%, word%)
- DECLARE SUB ClearBit (bitnumber%, word%)
- DECLARE SUB ToggleBit (bitnumber%, word%)
-
- WORD% is the 16-bit quantity where the selected bit resides.
- Set, Clear and ToggleBit alter WORD% directly.
-
- BITNUMBER% ranges from 1 to 16. If you exceed 16, what happens
- depends on what processor you're using. Zero affects no bits.
-
- ═══════════════
-
- DECLARE FUNCTION BitState% (bitnumber%, word%)
-
- Returns a logical "true" (-1) if the selected bit is set in WORD%, or a
- logical "false" (0) otherwise. WORD% is not altered.
-
- ═══════════════
-
- DECLARE FUNCTION BitStr$ (word%)
-
- Returns a 16-character string of ASCII ones and zeros with a "1" in
- each position where a bit is set in WORD%. For example, passing 12
- returns the string "0000000000001100".
-
- ═══════════════
-
- DECLARE FUNCTION BitVal& (binar$)
-
- Returns a long integer quantity reflecting the value of a passed string
- of ASCII ones and zeroes. BINAR$ can contain any number of digits, but
- only the first 16 are evaluated. If it contains fewer than 16 digits,
- they are considered as the less significant bits (i.e. "01" is taken to
- mean "0000000000000001" and evaluates to 1). Strings which contain
- *any* other character in the first 16 positions are rejected, and a
- value of zero returned.
-
- ═══════════════
-
-
- ----------------end-of-author's-documentation---------------
-
- Software Library Information:
-
- This disk copy provided as a service of
-
- The Public (Software) Library
-
- We are not the authors of this program, nor are we associated
- with the author in any way other than as a distributor of the
- program in accordance with the author's terms of distribution.
-
- Please direct shareware payments and specific questions about
- this program to the author of the program, whose name appears
- elsewhere in this documentation. If you have trouble getting
- in touch with the author, we will do whatever we can to help
- you with your questions. All programs have been tested and do
- run. To report problems, please use the form that is in the
- file PROBLEM.DOC on many of our disks or in other written for-
- mat with screen printouts, if possible. The P(s)L cannot de-
- bug programs over the telephone.
-
- Disks in the P(s)L are updated monthly, so if you did not get
- this disk directly from the P(s)L, you should be aware that
- the files in this set may no longer be the current versions.
-
- For a copy of the latest monthly software library newsletter
- and a list of the 2,000+ disks in the library, call or write
-
- The Public (Software) Library
- P.O.Box 35705
- Houston, TX 77235-5705
- (713) 524-6394
-